<include file="public@header"/>
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('Listen/index')}">监听列表</a></li>
        <li class="active"><a href="{:url('Listen/add')}">添加监听域名/粉丝页</a></li>
    </ul>
    <form action="{:url('Listen/addPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
        <div class="row">
            <div class="col-md-9">
                <table class="table table-bordered">
                    <tr>
                        <th width="100">域名<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control" type="text" name="domain" required value="" placeholder="domain" />
                        </td>
                    </tr>
                    <tr>
                        <th>联系电话<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control" type="text" name="phone" required value="" placeholder="phone"/>
                        </td>
                    </tr>
                    <tr>
                        <th>是否监听</th>
                        <td>
                            <select name="is_listen">
                                <option value="1">监听</option>
                                <option value="0">不监听</option>
                            </select>
                        </td>
                    </tr>
                </table>

                <button type="button" class="add btn "><span class="fa fa-plus">添加粉丝页</span></button><br/>

                <hook name="portal_admin_article_edit_view_main"/>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
                        <a class="btn btn-default" href="{:url('Listen/index')}">{:lang('BACK')}</a>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">


    $('.add').on('click', function () {

        var line = `
            <tr>
                <th>粉丝页链接<span class="form-required">*</span></th>
                <td style="display:flex;">
                    <input class="form-control" type="text" name="fanpages[]" value="" placeholder="输入粉丝页链接" required />
                    <button type="button" class="btn " onclick="deleme(this)"><span class="fa fa-minus"></span></button>
                </td>   
            </tr>`;


        $('.table-bordered').append(line);
    })

    function deleme(obj){
        var that = $(obj);
        var parent = that.parent().parent();
        // console.log(parent);
        parent.remove();
    }

    function doSelectCategory() {
        var selectedCategoriesId = $('#js-categories-id-input').val();
        openIframeLayer("{:url('AdminCategory/select')}?ids=" + selectedCategoriesId, '请选择分类', {
            area: ['700px', '400px'],
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                //do something

                var iframeWin          = window[layero.find('iframe')[0]['name']];
                var selectedCategories = iframeWin.confirm();
                if (selectedCategories.selectedCategoriesId.length == 0) {
                    layer.msg('请选择分类');
                    return;
                }
                $('#js-categories-id-input').val(selectedCategories.selectedCategoriesId.join(','));
                $('#js-categories-name-input').val(selectedCategories.selectedCategoriesName.join(' '));
                //console.log(layer.getFrameIndex(index));
                layer.close(index); //如果设定了yes回调，需进行手工关闭
            }
        });
    }
</script>
</body>
</html>
